<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('物品库存列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>物品名称：</label>
                            <input type="text" name="name"/>
                        </li>
                        <!--                        <li>-->
                        <!--                            <label>购买单价：</label>-->
                        <!--                            <input type="text" name="price"/>-->
                        <!--                        </li>-->
                        <!--                        <li>-->
                        <!--                            <label>数量：</label>-->
                        <!--                            <input type="text" name="quantity"/>-->
                        <!--                        </li>-->
                        <li>
                            <label>购买平台：</label>
                            <select name="platform">
                                <option value="">所有</option>
                                <option value="1">悠悠有品</option>
                                <option value="2">BUFF</option>
                                <option value="3">C5Game</option>
                                <option value="4">Steam</option>
                                <option value="5">IGXE</option>
                                <option value="6">ECO</option>
                            </select>
                        </li>
                        <li>
                            <label>购买账户：</label>
                            <select name="account">
                                <option value="">所有</option>
                                <option value="1">账号1</option>
                                <option value="2">账号2</option>
                                <option value="3">账号3</option>
                                <option value="4">账号4</option>
                                <option value="5">账号5</option>
                                <option value="6">账号6</option>
                            </select>
                        </li>
<!--                        <li>-->
<!--                            <label>购买时间：</label>-->
<!--                            <input type="text" class="time-input" placeholder="请选择购买时间" name="createDate"/>-->
<!--                        </li>-->
<!--                        <li>-->
<!--                            <label>更新时间：</label>-->
<!--                            <input type="text" class="time-input" placeholder="请选择更新时间" name="updateDate"/>-->
<!--                        </li>-->
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
            >
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
            >
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    // var editFlag = [[${@permission.hasPermi('system:record:edit')}]];
    // var removeFlag = [[${@permission.hasPermi('system:record:remove')}]];
    var prefix = ctx + "system/record";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "物品库存",
            pageSize: 20,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'account',
                    title: '购买账户',
                    sortable: true,
                    formatter: function (value, row, index) {
                        switch (value) {
                            case "1":
                                return '账户1';
                            case "2":
                                return '账户2';
                            case "3":
                                return '账户3';
                            case "4":
                                return '账户4';
                            case "5":
                                return '账户5';
                            case "6":
                                return '账户6';
                            default:
                                return '未知账户';
                        }
                    }
                },
                {
                    field: 'name',
                    title: '物品名称',
                    sortable: true
                },
                {
                    field: 'marketHashName',
                    title: '市场散列名称',
                    visible: false
                },
                {
                    field: 'price',
                    title: '购买单价',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return value / 100;
                    }
                },
                {
                    field: 'actual_price',
                    title: '实际单价',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (row.platform === "4") {
                            return (row.price * 0.8 / 100).toFixed(2);
                        } else {
                            return (row.price / 100).toFixed(2);
                        }
                    }
                },
                {
                    field: 'quantity',
                    title: '数量',
                    sortable: true
                },
                {
                    field: 'platform',
                    title: '购买平台',
                    sortable: true,
                    formatter: function (value, row, index) {
                        switch (value) {
                            case "1":
                                return '悠悠有品';
                            case "2":
                                return 'BUFF';
                            case "3":
                                return 'C5Game';
                            case "4":
                                return 'Steam';
                            case "5":
                                return 'IGXE';
                            case "6":
                                return 'ECO';
                            default:
                                return '未知';
                        }
                    }
                },
                {
                    field: 'totalBuyPrice',
                    title: '实际总价',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (row.platform === "4") {
                            return (row.price * 0.8 / 100 * row.quantity).toFixed(2);
                        } else {
                            return (row.price / 100 * row.quantity).toFixed(2);
                        }
                    }
                },
                {
                    field: 'createDate',
                    title: '购买时间',
                    sortable: true,
                    isAsc: 'desc'
                },
                {
                    field: 'updateDate',
                    title: '更新时间',
                    sortable: true,
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>